package com.study.springcloud;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Author raoluping
 * @Date 2017/10/26 11:50
 * @Description
 */
@EnableEurekaClient
@SpringBootApplication
// 启用feign进行远程调用
@EnableFeignClients
// 启动限流
@EnableHystrix
public class ConsumerApplication {

  public static void main(String[] args) {
    new SpringApplicationBuilder(ConsumerApplication.class).web(true).run(args);
  }

  // 向容器注入 RestTemplate，那么别的地方就可以通过注解引用了
  @Bean
  // 负载均衡
  @LoadBalanced
  RestTemplate restTemplate() {
    return new RestTemplate();
  }

}
